package com.wjh.pay.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 状态 枚举类
 * 
 * @author wenjianhai
 * @date 2023/6/21
 * @since JDK 17
 */
@Getter
@AllArgsConstructor
public enum StateEnum {
	/** 0:禁用 */
	DELETED(0, "禁用"),
	/** 1:正常 */
	NORMAL(1, "正常"),
	/** 2:冻结 */
	FREEZE(2, "冻结"),
	;

	private final Integer code;
	private final String name;

	/**
	 * 获取状态名称
	 *
	 * @param value
	 * @return String
	 */
	public static String getNameByValue(Integer code) {
		if (code == null) {
			return null;
		}
		for (StateEnum state : StateEnum.values()) {
			if (code.equals(state.getCode())) {
				return state.getName();
			}
		}
		return null;
	}
}
